﻿
<?php


  if(!empty($_POST)){


    //把表单的值存放到这三个变量中
      $power= implode(',',$_POST['power']); //将数组转成字符串

      $state=$_POST['state'];

      $name=$_POST['name'];


      $sql = "INSERT INTO `role`(`power`,`state`,`name`) VALUES ('$power','$state','$name')";
// print_r($sql);die;
           mysqli_query($link,'set names utf8');

          mysqli_query($link,$sql);

       $_rows=mysqli_affected_rows($link);
      //调用添加函数
     // $_rows = add('role',$_POST);

     if($_rows>=0){
          echo '<script>alert("角色添加成功");location.href="index.php?c=role&a=list&admin=1"; </script>';
     }else{
        echo '<script>alert("角色添加失败");history.go(-1) </script>';
     }
}


 //载入后台公共视图
    include_once (VIEW_PATH.'admin/layout.html');
?>